home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performCreatePond.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  6.1 KB  |  285 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Feb 2002
  22. //  Author:         dbrins 
  23. //
  24. //  Description:
  25. //
  26. //  Option box for the createPond command 
  27. //
  28.  
  29. //
  30. //  Procedure Name:
  31. //      setOptionVars
  32. //
  33. //  Description:
  34. //        Initialize the option values.
  35. //
  36. //  Input Arguments:
  37. //        Whether to set the options to default values.
  38. //
  39. //  Return Value:
  40. //      None.
  41. //
  42. proc setOptionVars(int $forceFactorySettings)
  43. {
  44.     if ($forceFactorySettings || !`optionVar -exists createPondSize`) {
  45.         optionVar -floatValue createPondSize 20.0;
  46.     }
  47. }
  48.  
  49. //
  50. //  Procedure Name:
  51. //      createPondSetup
  52. //
  53. //  Description:
  54. //        Update the state of the option box UI to reflect the option values.
  55. //
  56. //  Input Arguments:
  57. //      parent               - Top level parent layout of the option box UI.
  58. //                             Required so that UI object names can be 
  59. //                             successfully resolved.
  60. //
  61. //    forceFactorySettings - Whether the option values should be set to
  62. //                             default values.
  63. //
  64. //  Return Value:
  65. //      None.
  66. //
  67. global proc createPondSetup(string $parent, int $forceFactorySettings)
  68. {
  69.     //    Retrieve the option settings
  70.     //
  71.     setOptionVars($forceFactorySettings);
  72.  
  73.     setParent $parent;
  74.  
  75.     //    Query the optionVar's and set the values into the controls.
  76.  
  77.     floatSliderGrp -edit 
  78.         -v `optionVar -query createPondSize`
  79.         createPondSize;
  80.  
  81. }
  82.  
  83. //
  84. //  Procedure Name:
  85. //      createPondCallback
  86. //
  87. //  Description:
  88. //        Update the option values with the current state of the option box UI.
  89. //
  90. //  Input Arguments:
  91. //      parent - Top level parent layout of the option box UI.  Required so
  92. //               that UI object names can be successfully resolved.
  93. //
  94. //    doIt   - Whether the command should execute.
  95. //
  96. //  Return Value:
  97. //      None.
  98. //
  99. global proc createPondCallback(string $parent, int $doIt)
  100. {
  101.     setParent $parent;
  102.  
  103.     //    Set the optionVar's from the control values, and then
  104.     //    perform the command.
  105.  
  106.     optionVar -floatValue createPondSize
  107.         `floatSliderGrp -query -v createPondSize`;
  108.  
  109.     if ($doIt) {
  110.         performCreatePond 0;
  111.     }
  112. }
  113.  
  114. //
  115. //  Procedure Name:
  116. //      createPondOptions
  117. //
  118. //  Description:
  119. //        Construct the option box UI.  Involves accessing the standard option
  120. //        box and customizing the UI accordingly.
  121. //
  122. //  Input Arguments:
  123. //      None.
  124. //
  125. //  Return Value:
  126. //      None.
  127. //
  128. proc createPondOptions()
  129. {
  130.     //    Name of the command for this option box.
  131.     //
  132.     string $commandName = "createPond";
  133.  
  134.     //    Build the option box actions.
  135.     //
  136.     string $callback = ($commandName + "Callback");
  137.     string $setup = ($commandName + "Setup");
  138.  
  139.     string $layout = getOptionBox();
  140.     setParent $layout;
  141.     
  142.     setOptionBoxCommandName($commandName);
  143.     
  144.     setUITemplate -pushTemplate DefaultTemplate;
  145.  
  146.     waitCursor -state 1;
  147.  
  148.     tabLayout -tabsVisible 0 -scrollable 1;
  149.     
  150.     string $parent = `columnLayout -adjustableColumn 1`;
  151.     
  152.     floatSliderGrp
  153.         -label "Size"
  154.         -field 1
  155.         -min 0.0 
  156.         -max 100.0 
  157.         -fieldMinValue 0.0 
  158.         -fieldMaxValue 1000000.0
  159.         -pre 2
  160.         createPondSize;
  161.  
  162.     waitCursor -state 0;
  163.     
  164.     setUITemplate -popTemplate;
  165.  
  166.     //    'Create' button.
  167.     //
  168.     string $applyBtn = getOptionBoxApplyBtn();
  169.     button -edit
  170.         -label "Create Pond"
  171.         -command ($callback + " " + $parent + " " + 1)
  172.         $applyBtn;
  173.  
  174.     //    'Save' button.
  175.     //
  176.     string $saveBtn = getOptionBoxSaveBtn();
  177.     button -edit 
  178.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  179.         $saveBtn;
  180.  
  181.     //    'Reset' button.
  182.     //
  183.     string $resetBtn = getOptionBoxResetBtn();
  184.     button -edit 
  185.         -command ($setup + " " + $parent + " " + 1)
  186.         $resetBtn;
  187.  
  188.     setOptionBoxTitle("Create Pond");
  189.  
  190.     //    Customize the 'Help' menu item text.
  191.     //
  192.     setOptionBoxHelpTag( "CreatePond" );
  193.  
  194.     eval (($setup + " " + $parent + " " + 0));    
  195.     
  196.     showOptionBox();
  197. }
  198.  
  199. //
  200. //  Procedure Name:
  201. //      createPondHelp
  202. //
  203. //  Description:
  204. //        Return a short description about this command.
  205. //
  206. //  Input Arguments:
  207. //      None.
  208. //
  209. //  Return Value:
  210. //      string.
  211. //
  212. proc string createPondHelp()
  213. {
  214.     return 
  215.     "  Command: createPond - Create a fluid water surface simulation.\n" +
  216.     "Selection: None";
  217. }
  218.  
  219. //
  220. //  Procedure Name:
  221. //      assembleCmd
  222. //
  223. //  Description:
  224. //        Construct the command that will apply the option box values.
  225. //
  226. //  Input Arguments:
  227. //      None.
  228. //
  229. proc string assembleCmd()
  230. {
  231.     string $cmd = "createPond";
  232.  
  233.     setOptionVars(false);
  234.  
  235.     $cmd = ($cmd
  236.         + " " + `optionVar -query createPondSize` 
  237.         );
  238.  
  239.     return $cmd;
  240. }
  241.  
  242. //
  243. //  Procedure Name:
  244. //      performCreatePond
  245. //
  246. //  Description:
  247. //        Perform the createPond command using the corresponding 
  248. //        option values.
  249. //
  250. //  Input Arguments:
  251. //      0 - Execute the command.
  252. //      1 - Show the option box dialog.
  253. //      2 - Return the command.
  254. //
  255. global proc string performCreatePond(int $action)
  256. {
  257.     string $cmd = "";
  258.  
  259.     switch ($action) {
  260.  
  261.         //    Execute the command.
  262.         //
  263.         case 0:
  264.             $cmd = `assembleCmd`;
  265.             eval($cmd);
  266.             break;
  267.  
  268.         //    Show the option box.
  269.         //
  270.         case 1:
  271.             createPondOptions;
  272.             break;
  273.  
  274.         //    Return the command string.
  275.         //
  276.         case 2:
  277.             //    Get the command.
  278.             //
  279.             $cmd = `assembleCmd`;
  280.             break;
  281.     }
  282.     return $cmd;
  283. }
  284.  
  285.